import { RootState } from "../utils/store.type";
import { Module } from "vuex";

const waypointStatus: Module<any, RootState> = {
	namespaced: true,
	state: () => ({
		execMissionID: "",
		missionReachIndex: -1,
		missionState: "UNKNOWN",
		missionUploadedIndex: -1,
		missionExecState: "UNKNOWN",
		executeIDQuene: [],
	}),

	mutations: {
		statusUpdate(state, payload) {
			// console.log(state,payload);
			const json = JSON.parse(payload);
			Object.assign(state, json);
		},

		pushExecute(state, payload) {
			if (!(state.executeIDQuene as Array<string>).includes(payload)) {
				state.executeIDQuene.push(payload);
			}
		},

		clearExecute(state) {
			state.executeIDQuene = [];
		},

		updateExecuteID(state, payload) {
			state.execMissionID = payload;
		},
	},

	getters: {
		getExecuteID(state) {
			return state.executeIDQuene;
		},
	},

};

export 	default waypointStatus;
